package com.lgl;

import com.alibaba.fastjson.JSON;
import com.lgl.service.UserServiceImpl;
import com.lgl.zkclient.ZkClientTools;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.data.Stat;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.EmbeddedValueResolverAware;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: Brook
 * @Date: 2020/10/18 09:22
 * @Description:
 */
@SpringBootApplication
public class ServerBoot implements WebServerFactoryCustomizer<ConfigurableWebServerFactory> {

    public static void main(String[] args)  throws Exception {
        SpringApplication.run(ServerBoot.class, args);
        //启动服务器
        int port = 8888;
        String ipAddress = ZkClientTools.zkServerAddress;
        UserServiceImpl.startServer(ZkClientTools.nettyServerAddress, port);
        ZkClientTools.resisterToZookeeper("/server1", ZkClientTools.nettyServerAddress, port);
    }

    @Override
    public void customize(ConfigurableWebServerFactory factory) {
        factory.setPort(8085);
    }
}
